<template>
  <a-spin :spinning="spinning != 0">
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        :rowKey="rowKey"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="pagination"
        @change="handleTableChange"
        :customRow="clickThenCheck"
      >
        <template slot="serialNum" slot-scope="text,record,index">
          {{(pagination.current-1) * pagination.pageSize + parseInt(index) + 1}}
        </template>
      </a-table>
    </div>
  </a-spin>
</template>

<script>

  import YchConstant from "@/api/YchConstant";
  import {getAction} from '@/api/manage'
  import { filterMultiDictText } from '@/components/dict/YchDictSelectUtil'
  import { BpmConstant } from '@/views/bpm/BpmConstant'
  import {ViewMixin} from '@/mixins/ViewMixin'

  export default {
    name:'AssigneeStartProcessCountTopDetail',
    mixins: [ViewMixin],
    props: {
      beginDate: {
        type: String,
        required: false
      },
      endDate: {
        type: String,
        required: false
      },
      groupIds:{
        type: String,
        required: false
      },
    },
    data () {
      return {
        userId:"",
        url:{
          list:YchConstant.PREFIX_BPM + '/analyze/processAnalyzeRest/getAssigneeStartProcessCountTopDetail/v1',
        },

        columns: [
          {
            title:this.$t('m.common.label.number'),
            dataIndex: '',
            key: 'rowIndex',
            width: 50,
            align: "center",
            scopedSlots: { customRender: 'serialNum' },
          },
          {
            title: this.$t('m.bpm.entity.processDefName'),
            dataIndex: 'procDefName',
            align: 'center',
            width: 100,
            ellipsis: true,
          },
          {
            title: this.$t('m.bpm.entity.businessTitle'),
            dataIndex: 'businessTitle',
            align: 'center',
            width: 100,
            ellipsis: true,
          },
          {
            title: this.$t('m.bpm.entity.startUserName'),
            dataIndex: 'startUserName',
            align: 'center',
            width: 50,
          },
          {
            title: this.$t('m.bpm.entity.startTimeString'),
            dataIndex: 'startTime',
            align: 'center',
            width: 100,
          },
          {
            title: this.$t('m.bpm.entity.endTimeString'),
            dataIndex: 'endTime',
            align: 'center',
            width: 100,
          },
          {
            title:this.$t('m.common.label.status'),
            dataIndex: 'state',
            align: 'center',
            width: 50,
            customRender: (text) => {
              if (!text) {
                return ''
              } else {
                return filterMultiDictText(BpmConstant.processInstanceState, text)
              }
            }
          },

        ],
      }
    },
    created() {

    },
    methods: {
      loadData(arg,userId) {
        if (!this.url.list) {
          this.messageUtil.error("请设置url.list属性!")
          return
        }
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.pagination.current = 1;
          this.userId = userId
        }
        if(!this.userId){
          return
        }
        const params = this.getQueryParams();//查询条件
        params.beginDate = this.beginDate;
        params.endDate = this.endDate;
        params.groupIds = this.groupIds;
        params.userId = this.userId;
        this.spinning++;
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            this.dataSource = res.result.records;
            this.pagination.total = res.result.total;
          } else {
            this.messageUtil.warning(res.message);
          }
        }).finally(() => {
          this.spinning--;
        });
      },
    },
    /*    mounted () {
          this.loadData(1)
        },*/
  }
</script>
<style lang="less" scoped>
</style>
